package com.ruoyi.web.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.business.entity.YytMember;
import com.ruoyi.common.business.service.YytMemberService;
import com.ruoyi.common.ums.entity.YytUmsMemberLevel;
import com.ruoyi.common.ums.service.YytUmsMemberLevelService;
import com.ruoyi.utils.LoginUtils;
import com.ruoyi.utils.RedisService;
import com.ruoyi.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 会员等级 前端控制器
 * </p>
 *
 * @author MrPing
 * @since 2022-06-24
 */
@RestController
@RequestMapping("/member")
public class YytUmsMemberLevelController {

    @Autowired
    private YytUmsMemberLevelService yytUmsMemberLevelService;

    @Autowired
    private YytMemberService yytMemberService;

    /**
     * 获取用户所处的等级
     * @return
     */
    @GetMapping("/getUserEmpirical")
    public ResponseResult getUserEmpirical(String memberId){
        YytMember member = yytMemberService.getById(memberId);
        QueryWrapper<YytUmsMemberLevel> wrapper = new QueryWrapper<>();
        wrapper.le("growth_point", member.getGrowth()).gt("growth_point_end", member.getGrowth());
        return ResponseResult.success(yytUmsMemberLevelService.getOne(wrapper, true));
    }

}
